<div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="titlepage">
                        <h2>店铺信息</h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="brand-bg">
            <div class="container">
				<div class="usershow">
					<p class="hidden-val"></p>
					<div class="shoplogo">
						<img src="icon/Product-Sale-Flyer-Template-V-3-990x518.jpg"/>
					</div>
					<div class="shop-title">
						店铺名有这么大的呀
					</div>
				</div>
				<div class="search-item-shop col-md-12">
					<form>
						<input class="search" type="text" placeholder="搜素商品"/>
						<button id="shopinsearch" class="search-button" type="button">搜索商品</button>
					</form>
				</div>
				<div class="item-class-list">
					<p class="item-class-name">
						商品分类
					</p>

				</div>
				<div id="shop-items" class="row">
				</div>
			</div>
		</div>
<script type="text/javascript">
	$(function (){
		doGetShopMsg();
		doGetShopCats();
		doGetShopItem(null,null);
	});
	function doGetShopItem(catId,title){
		let shopId = $("#mainContentId").data("shopId");
		let url = `/ruoyi/shop/getitems`;
		let params = {"catId":catId,"title":title,"shopId":shopId};
		$.ajax({
			url:url,
			data: params,
			dataType:"json",
			success(result){
				if(result.status===200){
					doLoadShopItems(result.data);
					doLoadClick();
					doClickShopSearchItems();
				}
			},
			error(){
				alert("获取商品失败");
			}
		});
	}

	function doLoadShopItems(items){
		$("#shop-items").empty();
		for (let i in items){
			let itemdiv = $(`<div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 margin"></div>`);
			itemdiv.data("item",items[i]);
			itemdiv.append(doCreateItemShop(items[i]));
			$("#shop-items").append(itemdiv);
		}
	}

	function doCreateItemShop(item){
		return `<div class="item_box">
					<div class="item-name">
						<p class="hidden-val">${item.itemId}</p>
						<img src="${item.image}">
						<p>${item.title}</p>
						<p>价格: <span>${item.price}</span></p>
					</div>
				</div>`;
	}

	function doGetShopMsg(){
		let shopId = $("#mainContentId").data("shopId");
		let url = `/ruoyi/shop/getmsg`;
		$.ajax({
			url:url,
			data:{"shopId":shopId},
			dataType: "json",
			success(result) {
				if (result.status===200){
					doLoadmsg(result.data);
				}
			},
			error() {
				alert("获取店铺信息失败!");
			}
		});
	}

	function doLoadmsg(msg){
		$(".shoplogo").empty();
		$(".shoplogo").append(`<img src="${msg.logo}">`);
		$(".shop-title").text(`${msg.shopName}`);
	}

	function doGetShopCats(){
		let url = `/ruoyi/shop/getcats`;
		$.ajax({
			url: url,
			dataType: "json",
			success(result) {
				if (result.status === 200) {
					doLoadShopCats(result.data);
					doLoadClickShopCats();
				}
			},
			error() {
				alert("获取分类失败");
			}
		});
	}
	function doLoadClickShopCats(){
		$(".item-class-list div").click(function (){
			let catId = $(this).children(".hidden-val").text();
			doGetShopItem(catId,null);

		});
	}

	function doLoadShopCats(shopCats){
		for (let i in shopCats) {
			$(".item-class-list").append(`<div><span class="hidden-val">${shopCats[i].catId}</span>${shopCats[i].catName}</div>`);
		}
	}
</script>
<script type="text/javascript" src="js/ry/item.js"></script>